#include <stm32f4xx.h>
#include <stdint.h>
#include "dht11.h"
#include "delay.h"
#include "debug.h"
#include "string.h"


DHT11_t gDht11;
char show_buffer[100];

int main(void)
{
    Debug_Init(115200);
    Delay_Init();
    printf("DHT11 start\r\n");

    int ret = dht11_init(&gDht11, GPIOA, GPIO_Pin_6);
    printf("ret: %d\r\n", ret);
    while(1)
    {
        dht11_readvalue(&gDht11);
        memset(show_buffer, 0, sizeof(show_buffer));
        sprintf(show_buffer, "T: %0.2f   H: %0.2f\r\n", gDht11.temperature, gDht11.humidity);
        printf("%s", show_buffer);
        Delay_Ms(1000);
    }
}
